package com.weic.design.subject;

import com.weic.design.event.SubjectEvent;
import com.weic.design.observer.Observer;

import java.util.ArrayList;
import java.util.List;

/**
 * 抽象被观察对象
 * 具备添加和删除观察者的方法
 */
public abstract class Subject {
    List<Observer> observerList ;

    public void addObserver(Observer observer){
        observerList.add(observer);
    }

    public void deleteObserver(Observer observer){
        observerList.remove(observer);
    }

    /**
     * 提醒被观察者方法
     */
    public abstract void notifyObservers(SubjectEvent subjectEvent);
}
